package com.bigdata.movieticketapi.controller;

import com.bigdata.movieticketapi.common.pojo.PageResult;
import com.bigdata.movieticketapi.service.IAdminUserService;
import com.bigdata.movieticketapi.vo.req.LoginReqVO;
import com.bigdata.movieticketapi.vo.req.PageUserReqVO;
import com.bigdata.movieticketapi.vo.req.RegisterReqVO;
import com.bigdata.movieticketapi.vo.resp.AdminIndexDataRespVO;
import com.bigdata.movieticketapi.vo.resp.LoginRespVO;
import com.bigdata.movieticketapi.vo.resp.PageUserRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author movie
 * @since 2023-10-19
 */
@RestController
@RequestMapping("/api")
@Api(tags = "用户模块")
public class AdminUserController {

    @Resource
    private IAdminUserService iAdminUserService;


    /**
     * 后台用户接口，不对外开放，仅提供给admin用户进行用户注册
     * @param vo
     */
    @PostMapping("/admin/user/register")
    @ApiOperation(value = "注册接口")
    public void register(@RequestBody @Valid RegisterReqVO vo){
        iAdminUserService.register(vo);
    }

    /**
     * 后台用户登录接口
     * @param vo
     * @return
     */
    @PostMapping("/admin/user/login")
    @ApiOperation(value = "登录接口")
    public LoginRespVO login(@RequestBody @Valid LoginReqVO vo){
        return iAdminUserService.login(vo);
    }

    @PostMapping("/admin/user")
    @ApiOperation(value = "用户分页接口")
    public PageResult<PageUserRespVO> pageUsers(@RequestBody @Valid PageUserReqVO vo){
        return iAdminUserService.pageUsers(vo);
    }

    @PostMapping("/admin")
    @ApiOperation(value = "用户分页接口")
    public AdminIndexDataRespVO getAdminIndexData(){
        return iAdminUserService.getIndexData();
    }

}
